import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../components/Login.vue'
import Home from '../components/Home.vue'
<<<<<<< HEAD
import Welcome from '../components/Welcome.vue'
import User from '../components/user/User.vue'
<<<<<<< HEAD
import Rights from '../components/power/Rights.vue'
import Roles from '../components/power/Roles.vue'
<<<<<<< HEAD
import Cate from '../components/goods/Cate.vue'
<<<<<<< HEAD
import Params from '../components/goods/params.vue'
<<<<<<< HEAD
import GoodsList from '../components/goods/GoodsList.vue'
import Add from  '../components/goods/Add.vue'
import Order from '../components/order/Order.vue'
import Report from '../components/report/Report.vue'
=======
=======
=======
=======
=======
>>>>>>> 80ac5b9e90b4f636b9dca860f650629e44958aa0
>>>>>>> a79820c87ccfb914658132fe78def34964dcf529
>>>>>>> 4ab8c2302bcf0ba1e043216db4fea0fdcbcae751
>>>>>>> e5b07901b72d5f38ed1042a0e4d8aab07a4e1ada
>>>>>>> 2783cf938351f399feb03fa47c58d37cb2d2b849

Vue.use(VueRouter)


const router = new VueRouter({
  routes: [
    { path: '/', redirect: '/login' },
    { path: '/login', component: Login },
<<<<<<< HEAD
    { path: '/home', component: Home ,
    redirect:'/welcome',
    children:[
      {path:'/welcome',component:Welcome},
      {path:'/users',component:User},
      {path:'/rights',component:Rights},
      {path:'/roles',component:Roles},
      {path:'/categories',component:Cate},
      {path:'/params',component:Params},
       {path:'/goods',component: GoodsList},
       {path:'/goods/add',component:Add},
       {path:'/orders',component:Order},
       {path:'/reports',component:Report},
    ]},
    
  ]
})
// 挂载路由导航守卫
// router.beforeEach((to, from, next) => {
//   // to代表将要访问的路径，from代表从哪个路径跳转而来，next是一个函数表示放行
//   // next()放行   next('/login')强制跳转

//   // 如果路径是登录页，则直接放行
//   if (to.path === '/login') return next()
//   // 获取token从sessionStorage中
//   const tokenStr = window.sessionStorage.getItem('token')
//   if (!tokenStr) return next('/login')
//   next()
// })
=======
    { path: '/home', component: Home }
  ]
})
// 挂载路由导航守卫
router.beforeEach((to, from, next) => {
  // to代表将要访问的路径，from代表从哪个路径跳转而来，next是一个函数表示放行
  // next()放行   next('/login')强制跳转

  // 如果路径是登录页，则直接放行
  if (to.path === '/login') return next()
  // 获取token从sessionStorage中
  const tokenStr = window.sessionStorage.getItem('token')
  if (!tokenStr) return next('/login')
  next()
})
>>>>>>> 80ac5b9e90b4f636b9dca860f650629e44958aa0

export default router
